OpenLayers.LonLat.prototype.distanceFrom = function(lonlat){
	
	  if (!lonlat) {
		    return 0;
	  }

	  var R = 6371; // Radius of the Earth in km
	  var dLat = (lonlat.lat - this.lat) * Math.PI / 180;
	  var dLon = (lonlat.lon - this.lon) * Math.PI / 180;
	  var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
	    Math.cos(this.lat * Math.PI / 180) * Math.cos(lonlat.lat * Math.PI / 180) *
	    Math.sin(dLon / 2) * Math.sin(dLon / 2);
	  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
	  var d = R * c;
	  return d;
	  
//		var R = 6371; // km
//		var dLat = (lat2-lat1).toRad();
//		var dLon = (lon2-lon1).toRad(); 
//		var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
//		        Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) * 
//		        Math.sin(dLon/2) * Math.sin(dLon/2); 
//		var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
//		var d = R * c;
	  
};